﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BPO;
namespace PlotBookingRegistration
{
    public partial class HOME : Form
    {
        public HOME()
        {

            InitializeComponent();
        }

        private Security _SecInstance = Security.getInstance();
        public Security SecInstance { get { return _SecInstance; } }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            if(MessageBox.Show("Are you sure to log off from the system?","Logoff",MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            this.Close();
        }

        private void HOME_Load(object sender, EventArgs e)
        {
            if (SecInstance.IsUserLoggedIn)
            {
                lblWelcomeMessage.Text = "Welcome Dear "+ SecInstance.UserDetails.FullName.ToString() +" . You are logged in as "+ SecInstance.UserDetails.RoleName+"  at "+ DateTime.Now.ToString();
            }

            if (SecInstance.IsUserLoggedIn && SecInstance.UserRole != UserRoles.BranchManager)
            {
                btnRegister.Enabled = false;
                lblRegistration.Enabled = false;
            }
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            ShowRegistrationForm();
           
        }

        private void ShowRegistrationForm()
        {
            this.Hide();
            new Registration().ShowDialog();
        }

        private void btnPrinting_Click(object sender, EventArgs e)
        {
            this.Hide();
            new Printing().ShowDialog();
          
        }

        private void lblRegistration_Click(object sender, EventArgs e)
        {
            ShowRegistrationForm();
        }
    }
}
